//
// Created by hsj on 2022/3/3.
//
#include <iostream>
#include <cstdlib>
#include <ctime>
#ifndef CLION_CPP_T_DYNAMIC_CAST_H
#define CLION_CPP_T_DYNAMIC_CAST_H
namespace dynamic_cast_test{
    using std::cout;
    using std::cin;
    using std::endl;
    using std::rand;

    //关于const_cast<>： 唯一的作用删除const标签的限制
    //关于static_cast<>:


    class Grand{
        private:
            int hold;
        public:
            Grand(int hd = 0):hold(hd){}
            virtual ~Grand(){cout<<"Grand destory"<<endl;}

            virtual void speak()const{cout<<"I am a Grand Class."<<endl;}
            virtual int value()const{return hold;}
    };

    class SuperB: public Grand{
        public:
            SuperB(int hd = 0):Grand(hd){}
            virtual ~SuperB(){cout<<"SuperB destory"<<endl;}

            virtual void speak()const{cout<<"I am a SuperB Class."<<endl;}
            virtual void say()const{cout<<"I hold the SuperB value of: "<<value()<<endl;}
    };

    class Magnificent: public SuperB{
        private:
            char ch;
        public:
            Magnificent(int hd = 0,char c = 'A'):SuperB(hd),ch(c){}
            virtual ~Magnificent(){cout<<"Magnificent destory"<<endl;}

            virtual void speak()const{cout<<"I am a Magnificent Class."<<endl;}
            virtual void say()const{cout<<"I hold the Magnificent character: "<<ch<<endl
                                    <<"and the integer: "<<value()<<endl;}
    };


    //测试代码
    Grand *getOne();
    void test();
}

#endif //CLION_CPP_T_DYNAMIC_CAST_H
